import 'package:get/get.dart';
import 'package:wanandroid_flutter/utils/user.dart';

import 'home_controller.dart';

class MineController extends GetxController {
  var userName = "".obs;
  var userCoinCount = 0.obs;
  var homeController = Get.find<HomeController>();

  @override
  Future<void> onInit() async {
    super.onInit();
    var nikeName=await User().userName();
    if(nikeName!=""){
      userName.value =nikeName;
    }else{
      userName.value="登录";
    }
    userCoinCount.value = await User().userCoinCount();
  }

  updateUserInfo(String userName, int userCoinCount) {
    this.userName.value = userName;
    this.userCoinCount.value = userCoinCount;
  }

  clearLoginData(){
    updateUserInfo("",0);
    homeController.refreshRequest();
  }
}
